import datetime
import tabulate
from coin.strategy.accounting.pnl_balance_printer.pnl_balance_printer import SpotPnlBalancePrinter
from coin.exchange.kr_rest.product.product_impl import generate_product_from_str


class QuoinexPnlBalancePrinter(SpotPnlBalancePrinter):
  def __init__(self, *args, **kwargs):
    SpotPnlBalancePrinter.__init__(self, *args, **kwargs)

  def print_pnl_balance(self, *args, **kwargs):

    table = []
    for product in [generate_product_from_str('Quoinex', None, 'BTC-JPY')]:
      _, _, price = self._get_reserve_balance_price(product)
      table.append(['()', product.symbol, price])

    price_table_str = tabulate.tabulate(table, headers=['()', 'Symbol', 'Price'], floatfmt='.4f')
    self._logger.info('----- Symbol Price:\n* %s\n%s',
                      str(datetime.datetime.now()),
                      price_table_str)

    SpotPnlBalancePrinter.print_pnl_balance(self, *args, **kwargs)
